package pro.jiug.demo.job;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
import pro.jiug.demo.service.HelloService;

/**
 * @Author: liangyan
 * @Date: 2020/12/21 14:03
 * 继承QuartzJobBean类并重写executeInternal方法
 */
public class MyJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //获取传入的参数
        System.out.println(jobExecutionContext.getMergedJobDataMap().get("test"));
        HelloService helloService= (HelloService)jobExecutionContext.getMergedJobDataMap().get("helloService");
        helloService.sayHello();
    }
}
